<% @page_title = @discussion.title %>
<%= render :partial => 'disciplines/info_sidebar' %>
<div class="column first span-12">
  <%= breadcrumbs %>

  <div class="article">
    <h3 title="<%= @discussion.id %>"><%= link_to_unless_current @discussion.title, discipline_discussion_path(@discussion.discipline, @discussion) %></h3>
    <span class="byline">Posted <strong><%= date @discussion.created_at %></strong> by <%= link_to @discussion.user.name, profile_url(@discussion.user.login) %></span>
      <% if @discussion.user == current_user %>
        <span class="edit"><%= link_to 'edit',edit_discipline_discussion_path(@discussion.discipline, @discussion) %></span>
        &nbsp;
      <% end %>
      <% can_edit?(@discussion) do %>
        <span class="delete"><%= link_to 'delete',discipline_discussion_path(@discussion.discipline, @discussion), :method => :delete, :confirm => 'Are you sure you want to delete this?' %></span>
      <% end %>
      <br />
      <br />
      <%= white_list(simple_format(@discussion.body)) %>
    </div>

    <div class="comments">
    <% if @discussion.comments.count > 0 %><h3>Comments</h3><% end %>

    <% @discussion.comments.each do |comment| %>
      <% if comment.valid? %>
        <div class="comment">
          <span class="byline">Replied <strong><%= date comment.created_at %></strong> by <%= link_to comment.user.name, profile_url(comment.user.login) %></span>
          <% if logged_in? and current_user.admin? %>
            <span class="delete"><%= link_to 'Delete', discipline_discussion_discussion_comment_path(@discipline, @discussion, comment), :method => :delete, :confirm => 'Are you sure you want to delete this comment?' %></span>
          <% end %>
          <br />
          <br />
          <%= white_list(simple_format(comment.body)) %>
          <hr />
        </div>
      <% end %>
    <% end %>

      <% if logged_in? and current_user.member_of? @discipline %>
        <h3>add your comment</h3>
        <p></p>
        <%= sourdough_error_messages_for :comment %>
        <% form_for(:comment, :url => discipline_discussion_discussion_comments_path(@discipline, @discussion)) do |f| %>
          <dl>
            <dt></dt>
            <dd><%= f.text_area :body, :cols => 70 %></dd>
          </dl>
          <p><%= submit_tag "Add Comment" %></p>
        <% end %>
      <% else %>
        <p>You must log in and join this group to comment on a discussion</p>
      <% end %>

    </div>

</div>
